package tcln.sors.client.core.component.grid;

import java.util.Vector;

import tcln.sors.client.core.mvc.ModelData;

/**
 * Object which encapsulates data for a row in a {@link JGrid}.
 * 
 * @param <M>
 *            Underline model data type.
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
@SuppressWarnings("serial")
public class GridRowData<M extends ModelData<?>> extends Vector<Object> {

    /**
     * Underline model data.
     */
    private M model;

    /**
     * Constructs this row data from a model and default column count.
     * 
     * @param model
     */
    GridRowData(M model) {
        this.model = model;
    }

    /**
     * Constructs this row data from a model and expected column count.
     * 
     * @param model
     * @param columnCount
     */
    GridRowData(M model, int columnCount) {
        super(columnCount);
        this.model = model;
    }

    /**
     * Returns current value of {@link #model}.
     * 
     * @return the {@link #model}.
     */
    public M getModel() {
        return model;
    }

    /**
     * Clears the underline model data of this grid.
     */
    void clearModel() {
        this.model = null;
    }
}
